home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
FM Towns: Free Software Collection 6
/
FM Towns Free Software Collection 6.iso
/
ms_dos
/
nifp
/
nifptool.c
< prev
next >
Wrap
Text File
|
1993-07-08
|
25KB
|
1,128 lines
/*
* このモジュールは,NIFPのファイル選択サブルーチン部です。
* このモジュールは,マシン依存していません。
*
* nifptool.c COPYRIGHT TOOL 1991
*
*/
#include "nifp.h"
#define GETYEAR(x) ((((x & 0xfe00) >> 9) + 80) % 100)
#define GETMONTH(x) ((x & 0x1e0) >> 5)
#define GETDATE(x) (x & 0x1f)
#define GETHOUR(x) ((x & 0xf800) >> 11)
#define GETMIN(x) ((x & 0x7e0) >> 5)
#define GETSEC(x) ((x & 0x1f) << 2)
/* ディレクトリエントリ格納テーブルの構造体 */
struct dir_tree {
struct dir_tree *next;
struct dir_tree *back;
struct ffblk ffb;
};
static int sel_file(char *);
static int set_tree(struct ffblk, char *path);
static void treefree(void);
static int tree_disp(char *);
static void init_disp(char *);
static void filedisp(void);
static void updownstatus(void);
static void curdisp(int);
static void set_fdt(char *, struct dir_tree *);
static int getsetpath(char *);
static void updown2status(void);
static void file2disp(void);
static void cur2disp(int);
static void set2_fdt(char *,int);
static struct dir_tree *tree_top = NULL; /* テーブルの先頭 */
static struct dir_tree *tree_pos = NULL; /* テーブルの現在(最終)位置 */
/* ファイル一覧選択画面 */
static int fx = 16; /* 表示位置(桁) */
static int fy = 3; /* 表示位置(行) */
static int fn = 10; /* 表示行 */
static int fw = 47; /* 表示幅 */
static struct dir_tree *cur_top; /* 表示先頭位置 */
static struct dir_tree *cur_pos; /* 表示現在位置 */
static int cur_lno; /* 表示現在行位置 */
/* ログファイル選択画面 */
static int fx2 = 14; /* 表示位置(桁) */
static int fw2 = 52; /* 表示幅 */
static int cur2_top; /* 表示先頭位置 */
static int cur2_pos; /* 表示現在位置 */
static int cur2_lno; /* 表示現在行位置 */
struct dir2_tree *tree2_top = NULL; /* テーブルの先頭 */
struct dir2_tree *tree2_pos = NULL; /* テーブルの現在(最終)位置 */
void get_fdir(char *f,char *f1) {
char *a,buf[140];
int c;
memset(buf,0,140);
a = buf;
checkfile(f);
if(jstrchr(f,':')) { /* ドライブ指定有り */
c = *f - 'A' + 1;
*a++ = *f++;
f++;
}
else {
c = getdisk();
*a++ = c + 'A';
c++;
}
*a++ = ':';
if(*f != '\\') {
*a++ = '\\';
getcurdir(c,&buf[strlen(buf)]);
if(buf[strlen(buf)-1] != '\\')
strcat(&buf[strlen(buf)],"\\");
}
strcpy(&buf[strlen(buf)],f);
strcpy(f1,buf);
}
char datfile_s[140];
int datf_src(char *fname,int mode)
{
int i,k;
char buf[140],file[140],*w;
k = -1;
get_fdir(fname,file); /* フルパス名取得 */
for(i=0;datf[i];i++) {
_fstrcpy((char far *)buf,datf[i]);
if(!(w=jstrchr(buf,' '))) break;
*w = 0;
if(strcmp(buf,file)) continue;
k = i;
break;
}
if(mode) strcpy(datfile_s,file);
return(k);
}
void cgetfsx(char *msg, char *p)
{
int err;
while(1) {
xlocate();
kprintf(msg);
cgetsx(p,1); /* ファイル名入力 */
if(p[2] == 0x1b) {
p[2] = 0;
break; /* ESCキーの時には終了 */
}
err = sel_file(p); /* ファイル選択処理 */
p[1] = (char)strlen(&p[2]);
if(err != -1 && err != S_IFDIR) break; /* ディレクトリでないなら戻る */
if(p[2+strlen(&p[2])-1] != '\\') {
strcat(&p[2],"\\");
p[1]++;
}
}
xlocate();
}
static int sel_file(char *p)
{
struct ffblk ffb;
char path[129],path1[129];
int err;
while(1) {
if(tree_top) /* テーブル初期化 */
treefree();
err = getsetpath(&p[2]); /* 指定ディレクトリの整理 */
if(err == -1)
return(err);
if(err == (int)S_IFREG) /* 通常ファイルなら戻る */
return(0);
if(err != S_IFDIR)
return(err);
strcpy(path,&p[2]); /* テーブル作成 */
if(p[2+strlen(&p[2])-1] != '\\')
strcat(path,"\\");
strcpy(path1,path);
strcat(path,"*.*");
err = findfirst(path, &ffb,
FA_RDONLY|FA_HIDDEN|FA_SYSTEM|FA_DIREC|FA_ARCH);
if(err) return(-1);
while (!err) {
if(strcmp(ffb.ff_name, "."))
set_tree(ffb,path1);
err = findnext(&ffb);
}
err = tree_disp(p); /* 表示・キー入力処理 */
if(err == 0x1b)
return (S_IFDIR);
}
}
static int set_tree(struct ffblk ffdt,char *path)
{
struct dir_tree *tree_work,*tree_pit;
long i;
char fname[129],buf[140];
tree_work = tree_pos;
tree_pit = (struct dir_tree *)malloc(sizeof(struct dir_tree));
if(!tree_pit)
return(-1);
if(!(ffdt.ff_attrib & FA_DIREC)) {
strcpy(fname,path);
strcat(fname,ffdt.ff_name);
i = datf_src(fname,0);
if(i != -1) {
_fstrcpy((char far *)buf,datf[i]);
if(strstr(buf," @"))
ffdt.ff_attrib |= 0x80;
else
ffdt.ff_attrib |= 0x40;
}
}
if(tree_top && fsortmode) {
for(;tree_work;tree_work=tree_work->back) {
if(ffdt.ff_attrib & FA_DIREC) {
if(!strcmp(tree_work->ffb.ff_name,"..")) break;
if(!(tree_work->ffb.ff_attrib & FA_DIREC)) continue;
}
else {
if(tree_work->ffb.ff_attrib & FA_DIREC) break;
}
if(fsortmode >= 3) {
i = (long)ffdt.ff_fdate - (long)tree_work->ffb.ff_fdate;
if(!i) i = (long)ffdt.ff_ftime - (long)tree_work->ffb.ff_ftime;
if(i < 0) {
if(fsortmode & 1) continue;
break;
}
if(i > 0) {
if(fsortmode & 1) break;
continue;
}
}
i = jstrcmp(ffdt.ff_name,tree_work->ffb.ff_name);
if(i < 0) {
if(fsortmode & 1) continue;
break;
}
if(fsortmode & 1) break;
}
}
tree_pit->ffb = ffdt;
if(!tree_top) {
tree_top = tree_pos = tree_pit;
tree_pit->next = tree_pit->back = NULL;
}
else if(!tree_work) {
tree_pit->next = tree_top;
tree_top->back = tree_pit;
tree_top = tree_pit;
tree_pit->back = NULL;
}
else if(!tree_work->next) {
tree_work->next = tree_pos = tree_pit;
tree_pit->next = NULL;
tree_pit->back = tree_work;
}
else {
tree_pit->next = tree_work->next;
tree_work->next = tree_pit;
tree_pit->back = tree_work;
tree_pit->next->back = tree_pit;
}
return(0);
}
static void treefree(void)
{
struct dir_tree *work;
while(tree_top) {
work = tree_top;
tree_top = tree_top->next;
free((void *)work);
}
tree_top = tree_pos = NULL;
}
static int tree_disp(char *p)
{
char a,buf[81];
int i,j;
struct dir_tree *cur_wark;
fn = getline() - 6;
waku_disp(fx,fy,fn,fw,&p[2],"↑,↓,←,→,リターン,ESC"); /* 枠表示 */
cur_lno = 1;
cur_pos = cur_top = tree_top;
filedisp();
while (1) {
updownstatus();
curdisp(1);
a = keyget2(0);
a = cnvpfkey(a);
curdisp(0);
switch(a) {
case UEYA: /* ↑処理 */
if(cur_pos == tree_top) break;
cur_lno--;
cur_pos = cur_pos->back;
if(cur_lno < 1) {
cur_lno = 1;
cur_top = cur_top->back;
scroll(1,fx+1,fy+1,fx+fw,fy+fn);
set_fdt(buf, cur_pos);
loc(fx+1, fy+cur_lno);
deforutoiro();
print(buf);
}
break;
case SITAYA: /* ↓処理 */
if(!cur_pos->next) break;
cur_lno++;
cur_pos = cur_pos->next;
if(cur_lno > fn) {
cur_lno = fn;
cur_top = cur_top->next;
scroll(0,fx+1,fy+1,fx+fw,fy+fn);
set_fdt(buf, cur_pos);
loc(fx+1, fy+cur_lno);
deforutoiro();
print(buf);
}
break;
case HIDARIYA: /* ←処理 */
if(cur_pos == tree_top) break;
if(cur_top == tree_top)
cur_pos = tree_top;
else {
for(i = j = 0;i < fn;i++) {
if(cur_top == tree_top) {
j = 1;
break;
}
cur_top = cur_top->back;
}
if(j)
cur_pos = cur_top;
else {
for(i = 0;i < fn;i++)
cur_pos = cur_pos->back;
}
}
for(i = 1,cur_wark = cur_top;;i++) {
if(cur_pos == cur_wark) break;
cur_wark = cur_wark->next;
}
cur_lno = i;
filedisp();
break;
case MIGIYA: /* →処理 */
if(!cur_pos->next) break;
cur_wark = cur_top;
for(i = j = 0;i < fn;i++) {
if(!cur_wark->next) {
j = 1;
break;
}
cur_wark = cur_wark->next;
}
if(j) cur_pos = cur_wark;
else {
for(i = 0;i < fn;i++) cur_top = cur_top->next;
for(i = 0;i < fn;i++) {
if(!cur_pos->next) break;
cur_pos = cur_pos->next;
}
}
for(i = 1,cur_wark = cur_top;;i++) {
if(cur_pos == cur_wark) break;
cur_wark = cur_wark->next;
}
cur_lno = i;
filedisp();
break;
case KAIGYO: /* 改行 */
if(p[2+strlen(&p[2])-1] != '\\')
strcat(&p[2],"\\");
strcat(&p[2],cur_pos->ffb.ff_name);
return(a);
case ESC: /* ESC処理 */
return(a);
}
}
}
static void filedisp(void)
{
int i,j;
struct dir_tree *wk;
char buf[81];
wk = cur_top;
deforutoiro();
for(i=0; i<fn; i++) {
if(!wk) break;
set_fdt(buf,wk);
loc(fx+1,fy+1+i);print(buf);
wk = wk->next;
}
for(; i<fn; i++) {
for(j=0; j<fw; j++) {
loc(fx+1+j,fy+1+i);print(" ");
}
}
}
static void updownstatus(void)
{
int i,j;
struct dir_tree *cur_wark;
loc(fx+fw-3,fy+fn+1);
if(cur_top != tree_top) {
iro(IUP);print("↑");
}
else {
iro(IFWAKU);print(" ");
}
cur_wark = cur_top;
for(i = j = 0;i < fn;i++) {
if(!cur_wark->next) {
j = 1;
break;
}
cur_wark = cur_wark->next;
}
loc(fx+fw-1,fy+fn+1);
if(!j) {
iro(IDOWN);print("↓");
}
else {
iro(IFWAKU);print(" ");
}
}
static void curdisp(int c_mode)
{
char buf[81];
set_fdt(buf, cur_pos);
loc(fx+1, fy+cur_lno);
if(c_mode) iro(IFCUR);
else deforutoiro();
print(buf);
}
static void set_fdt(char *ptr, struct dir_tree *tr)
{
char wkdt[16],*p,work[50],c;
char attr_disp[10]="";
if (tr->ffb.ff_attrib & FA_RDONLY)
strcat(attr_disp, " R");
else
strcat(attr_disp, " _");
if (tr->ffb.ff_attrib & FA_HIDDEN)
strcat(attr_disp, " H");
else
strcat(attr_disp, " _");
if (tr->ffb.ff_attrib & FA_SYSTEM)
strcat(attr_disp, " S");
else
strcat(attr_disp, " _");
if (tr->ffb.ff_attrib & FA_ARCH)
strcat(attr_disp, " A");
else
strcat(attr_disp, " _");
if(tr->ffb.ff_attrib & 0x80) c = '*';
else if(tr->ffb.ff_attrib & 0x40) c = '+';
else c = ' ';
if(tr->ffb.ff_attrib & FA_DIREC) {
strcpy(wkdt,tr->ffb.ff_name);
strcat(wkdt,"\\");
sprintf(ptr," %-13s <DIR>",wkdt);
}
else {
strcpy(wkdt, tr->ffb.ff_name);
if((p = strchr(wkdt,'.'))) {
*p = NULL;
sprintf(ptr," %c%-8s.%-3s %7ld",c,wkdt,p+1,tr->ffb.ff_fsize);
}
else sprintf(ptr," %c%-8s. %7ld",c,wkdt,tr->ffb.ff_fsize);
}
sprintf(work," %02d-%02d-%02d %02d:%02d %s ",
GETYEAR(tr->ffb.ff_fdate),
GETMONTH(tr->ffb.ff_fdate),
GETDATE(tr->ffb.ff_fdate),
GETHOUR(tr->ffb.ff_ftime),
GETMIN(tr->ffb.ff_ftime),
attr_disp);
strcat(ptr,work);
}
static int getsetpath(char *ptr)
{
struct stat st;
char *p1,c_dev,s_dev,c_dir[256],s_dir[256];
int l;
l = strlen(ptr);
if(ptr[l-1] == '\\')
if(l != 1 && ptr[l-2] != ':')
ptr[l-1] = NULL;
c_dev = getdisk() + 'A';
if(!(p1 = jstrchr(ptr,':'))) { /* ドライブ指定なし */
getcwd(c_dir,255);
s_dev = c_dev;
if(strlen(ptr)) {
if(chdir(ptr)) { /* ディレクトリではない */
chdir(c_dir);
return(S_IFREG);
}
}
getcwd(s_dir,255);
chdir(c_dir);
}
else {
s_dev = toupper(*(p1-1));
setdisk(s_dev - 'A');
getcwd(c_dir,255);
if(strlen(p1+1)) {
if(chdir(p1+1)) { /* ディレクトリではない */
setdisk(c_dev - 'A');
chdir(c_dir);
return(S_IFREG);
}
getcwd(s_dir,255);
setdisk(c_dev - 'A');
chdir(c_dir);
}
else {
*ptr = s_dev;
*(ptr+1) = NULL;
strcat(ptr,":\\");
strcpy(s_dir,ptr);
}
setdisk(c_dev - 'A');
}
strcpy(ptr,s_dir);
if(stat(ptr,&st)) {
if(!(p1 = strchr(ptr,':'))) return(-1);
if(*(p1+1) != '\\') return(-1);
else return(S_IFDIR);
}
if((st.st_mode & S_IFMT) == S_IFDIR) return(S_IFDIR);
if((st.st_mode & S_IFMT) == S_IFREG) return(S_IFREG);
return(-1);
}
int filechoice(int fno)
{
char a,buf[81];
fn = getline() - 6;
waku_disp(fx2,fy,fn,fw2,"ログファイルを選択してください",
"↑,↓,←,→,リターン,ESC");
cur2_lno = fno - ((fno-1) / fn) * fn;
cur2_top = ((fno-1) / fn) * fn + 1;
cur2_pos = fno;
file2disp();
while (1) {
updown2status();
cur2disp(1);
a = keyget2(0);
a = cnvpfkey(a);
cur2disp(0);
switch(a) {
case UEYA: /* ↑処理 */
if(cur2_pos == 1) break;
cur2_lno--;
cur2_pos--;
if(cur2_lno < 1) {
cur2_lno = 1;
cur2_top--;
scroll(1,fx2+1,fy+1,fx2+fw2,fy+fn);
set2_fdt(buf, cur2_pos);
loc(fx2+1, fy+cur2_lno);
deforutoiro();
print(buf);
}
break;
case SITAYA: /* ↓処理 */
if(cur2_pos == maxfno) break;
cur2_lno++;
cur2_pos++;
if(cur2_lno > fn) {
cur2_lno = fn;
cur2_top++;
scroll(0,fx2+1,fy+1,fx2+fw2,fy+fn);
set2_fdt(buf, cur2_pos);
loc(fx2+1, fy+cur2_lno);
deforutoiro();
print(buf);
}
break;
case HIDARIYA: /* ←処理 */
if(cur2_pos == 1) break;
if(cur2_top == 1)
cur2_pos = cur2_lno = 1;
else {
cur2_top -= fn;
cur2_pos -= fn;
if(cur2_top < 1)
cur2_top = cur2_pos = cur2_lno = 1;
}
file2disp();
break;
case MIGIYA: /* →処理 */
if(cur2_pos == maxfno) break;
if(cur2_top+fn > maxfno)
cur2_pos = maxfno;
else {
cur2_top += fn;
cur2_pos += fn;
if(cur2_pos >= maxfno)
cur2_pos = maxfno;
}
cur2_lno = cur2_pos - cur2_top + 1;
file2disp();
break;
case KAIGYO: /* 改行 */
return(cur2_pos);
case ESC: /* ESC */
return(0);
}
}
}
static void updown2status(void)
{
loc(fx2+fw2-3,fy+fn+1);
if(cur2_top != 1) {
iro(IUP);print("↑");
}
else {
iro(IFWAKU);print(" ");
}
loc(fx2+fw2-1,fy+fn+1);
if(cur2_top+fn <= maxfno) {
iro(IDOWN);print("↓");
}
else {
iro(IFWAKU);print(" ");
}
}
static void file2disp(void)
{
int i,j;
int wk;
char buf[81];
wk = cur2_top;
deforutoiro();
for(i=0; i<fn; i++) {
if(wk > maxfno) break;
set2_fdt(buf,wk);
loc(fx2+1,fy+1+i);print(buf);
wk++;
}
for(; i<fn; i++) {
for(j=0; j<fw2; j++) {
loc(fx2+1+j,fy+1+i);print(" ");
}
}
}
static void cur2disp(int c_mode)
{
char buf[81];
set2_fdt(buf, cur2_pos);
loc(fx2+1, fy+cur2_lno);
if(c_mode) iro(IFCUR);
else deforutoiro();
print(buf);
}
static void set2_fdt(char *ptr, int tr)
{
char *a,buf[21],w1[21],w2[17],ww[129],bufw[140];
struct stat sbuf;
struct tm *jtime;
int i;
char attr_disp[10]="";
_fstrcpy((char far *)ww,file[tr-1]);
if(!(a = strrchr(ww,'\\')) && !(a = strrchr(ww,':')))
a = ww;
else a++;
strcpy(buf,a);
sprintf(ptr," %3d: ",tr);
if(stat(ww,&sbuf) || sbuf.st_mode & S_IFDIR) {
if((a = strchr(buf,'.'))) {
*a = NULL;
sprintf(w1," %-8s.%-3s",buf,a+1);
}
else sprintf(w1, "%-8s. ",buf);
strcat(ptr,w1);
strcat(ptr," ### deleted ###");
}
else {
i = datf_src(ww,0);
if(i != -1) {
_fstrcpy((char far *)bufw,datf[i]);
if(strstr(bufw," @")) strcat(ptr,"*");
else strcat(ptr,"+");
}
else strcat(ptr," ");
if((a = strchr(buf,'.'))) {
*a = NULL;
sprintf(w1,"%-8s.%-3s %7ld",buf,a+1,sbuf.st_size);
}
else sprintf(w1,"%-8s. %7ld",buf,sbuf.st_size);
timezone = 8 * 60 * 60;
jtime = localtime(&sbuf.st_atime);
sprintf(w2," %02d-%02d-%02d %02d:%02d",
jtime->tm_year,jtime->tm_mon+1,jtime->tm_mday,
jtime->tm_hour,jtime->tm_min);
strcat(ptr,w1);
strcat(ptr,w2);
if(sbuf.st_mode & S_IWRITE)
strcat(attr_disp, " _");
else
strcat(attr_disp, " R");
strcat(attr_disp, " _ _ A");
strcat(ptr,attr_disp);
}
strncat(ptr,space,fw2-strlen(ptr));
for(i = 0;ptr[i];i++) {
if(iskanji(ptr[i]) && iskanji2(ptr[i+1])) {
i++;
continue;
}
ptr[i] = toupper(ptr[i]);
}
}
int checkfile(char *path)
{
int i;
struct stat sbuf;
if(!path) return(0);
for(i = 0;path[i];i++) {
if(iskanji(path[i]) && iskanji2(path[i+1])) {
i++;
continue;
}
path[i] = toupper(path[i]);
}
if(stat(path,&sbuf) || (sbuf.st_mode & S_IFDIR))
return(0);
if(!sbuf.st_size) return(-1);
return(1);
}
int set2_tree(char *ww)
{
struct dir2_tree *tree2_work,*tree2_pit;
long i;
char *a,buf[21];
struct stat sbuf;
if(!(a = strrchr(ww,'\\')) && !(a = strrchr(ww,':')))
a = ww;
else a++;
strcpy(buf,a);
if(stat(ww,&sbuf)) return(-2);
if(!sbuf.st_size) return(-3);
tree2_work = tree2_pos;
tree2_pit = (struct dir2_tree *)malloc(sizeof(struct dir2_tree));
if(!tree2_pit)
return(-1);
if(tree2_top && fsort2mode) {
for(;tree2_work;tree2_work=tree2_work->back) {
if(fsort2mode >= 3) {
i = (long)sbuf.st_atime - (long)tree2_work->sbuf.st_atime;
if(i < 0) {
if(fsort2mode & 1) continue;
break;
}
if(i > 0) {
if(fsort2mode & 1) break;
continue;
}
}
i = jstrcmp(buf,tree2_work->name);
if(i < 0) {
if(fsort2mode & 1) continue;
break;
}
if(fsort2mode & 1) break;
}
}
tree2_pit->sbuf = sbuf;
strcpy(tree2_pit->name,buf);
tree2_pit->file = (char far *)farmalloc((long)strlen(ww)+1);
if(tree2_pit->file) _fstrcpy(tree2_pit->file,(char far *)ww);
if(!tree2_top) {
tree2_top = tree2_pos = tree2_pit;
tree2_pit->next = tree2_pit->back = NULL;
}
else if(!tree2_work) {
tree2_pit->next = tree2_top;
tree2_top->back = tree2_pit;
tree2_top = tree2_pit;
tree2_pit->back = NULL;
}
else if(!tree2_work->next) {
tree2_work->next = tree2_pos = tree2_pit;
tree2_pit->next = NULL;
tree2_pit->back = tree2_work;
}
else {
tree2_pit->next = tree2_work->next;
tree2_work->next = tree2_pit;
tree2_pit->back = tree2_work;
tree2_pit->next->back = tree2_pit;
}
return(0);
}
void tree2free(void)
{
struct dir2_tree *work;
while(tree2_top != NULL) {
work = tree2_top;
tree2_top = tree2_top->next;
free((void *)work);
}
tree2_top = NULL;
tree2_pos = NULL;
}
void set_cmdcopy(char *buf,int c,PCELL far *tcu,char *fname,int lno)
{
char s[41],w[13],work[81],work1[81],a,w1[9],*o,*p;
int i,j,k;
PCELL far *wk;
char c1=0,c2=0;
long l;
for(i=j=0;(a=gfilename[i++]) && (a != '.');) {
w1[j++] = a;
}
w1[j] = 0;
strcpy(s,cmdtbl[c]);
for(i=j=0;s[i];i++) {
tbl_set(tcu);
if(iskanji(s[i]) && iskanji2(s[i+1])) {
buf[j++] = s[i++];
buf[j++] = s[i];
continue;
}
if(s[i] == '%') {
o = &s[i+1];
if(p = jstrchr(o,'%')) {
*p++ = 0;
strcpy(work,o);
strupr(work);
i += strlen(o) + 1;
if(o = getenv(work)) {
strcpy(&buf[j],o);
j += strlen(o);
}
continue;
}
}
if(s[i] == '$') {
switch(s[++i]) {
case 'i': if(tcu->p->nifid[0]) {
_fmemcpy((char far *)&buf[j],tcu->p->nifid,8);
k = 8;
}
else k = 0;
break;
case 'c': sprintf(w,"%2d",tcu->p->id);
memcpy(&buf[j],w,2);
k = 2;
break;
case 'f': strcpy(&buf[j],filename);
k = strlen(filename);
break;
case 'X': strcpy(&buf[j],gfilename);
k = strlen(gfilename);
break;
case 'x': strcpy(&buf[j],w1);
k = strlen(w1);
break;
case 'k': strcpy(&buf[j],kiridir);
k = strlen(kiridir);
break;
case 'h': strcpy(&buf[j],hatudir);
k = strlen(hatudir);
break;
case 't': strcpy(&buf[j],titledir);
k = strlen(titledir);
break;
case 'p': if(strlen(fname)) {
strcpy(&buf[j],fname);
k = strlen(fname);
}
else {
strcpy(&buf[j],"$p");
k = 2;
}
break;
case 'P': if(strlen(fname)) {
strcpy(&buf[j],fname);
k = strlen(fname);
}
else {
strcpy(&buf[j],"$P");
k = 2;
}
break;
case 'F':
set_cmd00: memset(work,0,9);
wk = tcu->grp;
tbl_set(wk);
_fstrncpy((char far *)work,wk->p->nifid,8);
strcpy(&buf[j],work);
k = strlen(work);
break;
case 'I': if(tcu->grp->mode == NHPHEAD)
goto set_cmd00;
break;
case 'K': k = 0;
break;
case 'l': if(tcu->mode != NSEPA) l = tcu->p->lineno;
else {
wk = tcu->next;
tbl_set(wk);
l = wk->p->lineno;
tbl_set(tcu);
}
sprintf(w,"%ld",l + lno - 1);
k = strlen(w);
strcpy(&buf[j],w);
break;
case 'A': memset(work,0,9);
memset(work1,0,9);
wk = tcu->grp;
tbl_set(wk);
_fstrncpy((char far *)work,wk->p->nifid,8);
switch(wk->mode) {
case NFBBSHEAD:
case NMESHEAD:
case NFRTHEAD:
case NFRSHEAD:
case NLIBHEAD:
if(strlen(work) < 7) strcpy(work1,work);
else {
strncpy(work1,work,4);
if(strlen(work) < 8)
strcat(&work1[4],&work[5]);
else
strcat(&work1[4],&work[6]);
}
break;
default:
strcpy(work1,work);
}
strcpy(&buf[j],work1);
k = strlen(work1);
break;
case 'B': memset(work,0,9);
wk = tcu->grp;
tbl_set(wk);
k = wk->p->cno;
switch(wk->mode) {
case NFBBSHEAD: k = 21;
case NMESHEAD: c1 = '_'; c2 = '~'; break;
case NFRTHEAD:
case NFRSHEAD: c1 = '%'; c2 = '&'; break;
case NLIBHEAD: c1 = '#'; c2 = '$'; break;
default: k = -1;
}
if(k > 0) {
work[0] = 0;
if(k < 11) {
if(c1) {
if(k != 10) sprintf(work,"%c%d",c1,k);
else sprintf(work,"%cA",c1);
}
}
else {
if(c2) {
if(k < 20) sprintf(work,"%c%d",c2,k-10);
else if(k == 20) sprintf(work,"%cA",c2);
else sprintf(work,"%cB",c2);
}
}
strcpy(&buf[j],work);
}
k = strlen(work);
break;
default: buf[j] = s[i]; k = 1; break;
}
j += k;
continue;
}
buf[j++] = s[i];
}
buf[j] = 0;
}
static void set_cmdstring(char *buf,int i,PCELL far *tcu,int lno)
{
char work[256],c;
if(i < 10) c = '0'+i;
else c = 'A'+i-10;
set_cmdcopy(work,i-1,tcu,"",lno);
if(cmdtbl[i-1]) sprintf(buf," %c : %s",c,work);
else sprintf(buf," %c :",c);
strncat(buf,space,72-strlen(buf));
}
int comand_disp(PCELL far *tcu,int lno)
{
char a,b,buf[256];
int i,j;
waku_disp(4,3,15,72,
"起動コマンドを選択してください","数字,A~F,↑,↓,リターン,ESC"); /* 枠表示 */
for(i=1; i<=15; i++) {
set_cmdstring(buf,i,tcu,lno);
loc(4+1,3+i);print(buf);
}
for(i=1;;) {
set_cmdstring(buf,i,tcu,lno);
loc(4+1, 3+i);
iro(IFCUR);print(buf);
a = keyget2(0);
b = cnvpfkey(a);
loc(4+1, 3+i);
deforutoiro();print(buf);
if(a >= 0x81 && a <= 0x8f) {
j = (int)(a - 0x81);
if(strlen(cmdtbl[j]))
return(j);
continue;
}
if(a >= 'a' && a <= 'f') {
j = (int)(a - 'a'+9);
if(strlen(cmdtbl[j]))
return(j);
continue;
}
if(a >= 'A' && a <= 'F') {
j = (int)(a - 'A'+9);
if(strlen(cmdtbl[j]))
return(j);
continue;
}
switch(b) {
case UEYA: /* ↑処理 */
if(i <= 1) break;
i--;
break;
case SITAYA: /* ↓処理 */
if(i >= 15) break;
i++;
break;
case KAIGYO: /* 改行 */
if(!strlen(cmdtbl[i-1])) break;
return(i-1);
case ESC: /* ESC処理 */
return(-1);
}
}
}
void waku_disp(int x,int y,int n,int w,char *ptr,char *ptr1)
{
int i, j;
char buf[81];
loc(x-1,y);deforutoiro();print(" ");
iro(IFWAKU);
/* for(i=0; i<(w+2); i++) {
buf[i] = ' ';
}
buf[i] = 0; */
xxstrncpy(buf,space,w+2);
loc(x,y);print(buf);
loc(x+w+2,y);deforutoiro();print(" ");
loc(x+1,y);iro(IFWAKU);print(ptr);
xxstrncpy(buf,space,w);
for(i=y+1; i<(y+n+1); i++) {
loc(x-1,i);deforutoiro();print(" ");
loc(x,i);iro(IFWAKU);print(" ");
deforutoiro();
/* for(j=0; j<w; j++) {
buf[j] = ' ';
} */
loc(x+1,i);print(buf);
loc(x+w+1,i);iro(IFWAKU);print(" ");
loc(x+w+2,i);deforutoiro();print(" ");
}
loc(x-1,y+n+1);deforutoiro();print(" ");
iro(IFWAKU);
/* for(i=0; i<(w+2); i++) {
buf[i] = ' ';
} */
xxstrncpy(buf,space,w+2);
loc(x,y+n+1);print(buf);
loc(x+w+2,y+n+1);deforutoiro();print(" ");
i = x + w - strlen(ptr1) - 4;
loc(i,y+n+1);iro(IFWAKU);print(ptr1);
deforutoiro();
}
static char *grh_string="|----+----+----+----+----+----+----+----+----+----|";
void grh_disp(char *ptr,int mode) {
waku_disp(12,8,3,55,ptr,mode ? "ESCキーで中断" : "");
loc(14,9);
print("0% 10 20 30 40 50 60 70 80 90 100%");
loc(14,10);
print(grh_string);
}
void grh_sub(long nn,long tt) {
unsigned long i,n,t;
char buf[51];
n = nn;
t = tt;
if(n && t) {
i = (n * 50)/ t;
memset(buf,0,51);
strncpy(buf,grh_string+1,i);
loc(15,10);iro(ITITLE);
print(buf);
deforutoiro();
}
else {
loc(14,10);
print(grh_string);
}
}